<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>已登录用户列表</title>
<%@ include file="/WEB-INF/jsp/common/inc.jsp" %>
<link rel="stylesheet" href="${_resources}bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="${_resources}bootstrap/bootstrap-table.min.css" />
<script type="text/javascript" src="${_resources}jquery-ui/jquery-ui-1.10.4.custom.min.js"></script>
<link rel="stylesheet" href="${_resources}jquery-ui/jquery-ui-1.10.4.custom.min.css" />
<script type="text/javascript" src="${_resources}JSON-js-master/json2.js"></script>
<script type="text/javascript">
var menuList;
var deptNameMap;
var customCode = "${numCode}";
var userId="<%=session.getAttribute("user_id")%>";

if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt /*, from*/)
  {
    var len = this.length >>> 0;

    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0)
      from += len;

    for (; from < len; from++)
    {
      if (from in this &&
          this[from] === elt)
        return from;
    }
    return -1;
  };
}


$(function (){
	menuList = $("#menuList").bootstrapTable({
		url : '${_baseUrl}/userController/selectLoginList?random='+Math.random(),
		pagination: true,
		pageList: [5, 10, 20, 50],
  		queryParams: queryParams,
        columns: [{
             title: '序号',
             width: 45,
             formatter: function(value, row, index){
 	            	return index+1;
             }
         }, {
            field: 'userName',
            title: '姓名',
            width: 90
        },
        {
            field: 'userId',
            title: '用户账号',
            width: 90
        },
        {
            field: 'iP',
            title: '用户IP',
            width: 80
        },
        {
            field: 'loginTime',
            title: '登录时间',
            width: 80
        },
        {
            field: 'deptName',
            title: '部门',
            width: 80
        },{
            field: 'officeTelephone',
            title: '办公电话',
            width: 100
        },{
            // field: 'destroy',
            title: '操作',
            width: 100,
            formatter: function(value, row, index){
            	if(userId != row.id){
            		return "<a href='javascript:void(0)' onclick=\"delUser('"+row.id+"')\">注销</a>";
            	}
              }
        }]
    });
	
	function queryParams(params){
		return {
		    pageSize: params.limit,
		    pageNo: params.pn,
		    sort : params.sort,
		    order : params.order,
		    userNameForSerch:$("#userNameForSerch").val()
	   }
	}
	if("${customCode}" != 'tianjin712suo'){
		 $('#menuList').bootstrapTable('hideColumn', 'destroy');
	}  
	$("#userNameForSerch").keydown(function(event) {//给输入框绑定按键事件
	    if(event.keyCode == "13") {//判断如果按下的是回车键则执行下面的代码
	    	refreshTable();
	  	}
	})
	
});
/* 排序 */
function sortFun(id,sort,type){
	 var path="${_baseUrl}/userController/updateSort";
	 $.ajax({    
			type: "POST",    
			async: false,    
			url:path,   
			data:{
				"id":id,
				"sort":sort,
				"type":type
			},    
			dataType:"text",    
			success: function (data) {   
				layer.msg(data,{shift:5,time:1000},function(){
					refreshTable();//刷新当前页面.		
				});
			}   
		});                
}
function delUser(id){
		var path="${_baseUrl}/userController/sessionDestroy";
		 $.ajax({    
				type: "POST",    
				async: false,    
				url:path,   
				data:{
					"id":id
				},    
				dataType:"text",    
				success: function (data) {  
					layer.msg("注销成功",{shift:5,time:3000},function(){
					refreshTable();
				    });
				}
			});  
}

/* 关闭弹出框 */
function closeWin(){
	layer.closeAll();
}

function refreshTable(){
	menuList.bootstrapTable('refresh');
}
</script>
<style type="text/css">
.fixed-table-container{border:0px}
table{border:1px solid #ddd;margin-top: 7px!important;}
.fixed-table-header{height:0px}
</style>
</head>
<body>
<div class="submenu">
    <div  class="func_header">
        <span title="用户管理>用户列表">当前位置 ： <a href="javascript:;">用户管理</a>>已登录用户列表</span>
    </div>
    <div class="func_bar">
    	<div class="search_container">
	        <div class="func_search">
	        	<div class="func_search_div"></div>
	            <input type="text" id="userNameForSerch" name="user_date" value="" placeholder="请输入关键词" />
	            <a class="search_btn" id="search" href="javascript:;" onclick="refreshTable()"></a>
	        </div>
        </div>
       <%--  <div class="btn_container">
        	<shiro:hasPermission name="userController:addPage">
		        <a href="javascript:;" class="blue_btn" onClick="addFun();">添加人员</a>
		    </shiro:hasPermission>
		    <shiro:hasPermission name="userController:updateLogout">
	            <a class="blue_btn" id="cancellationPersonnel" onclick="logoutFun()" href="javascript:;">注销人员</a>
		    </shiro:hasPermission>
		    <shiro:hasPermission name="userController:PwdReset">
	            <a class="blue_btn" id="passwordReset" href="javascript:;" onclick="pwdResetFun()">密码重置</a>
		    </shiro:hasPermission>
		    <shiro:hasPermission name="userController:showBatchImport">
	            <a class="blue_btn" id="batchImport" href="javascript:;" onClick="batchImport();">批量导入</a>
		    </shiro:hasPermission>
		    <shiro:hasPermission name="userController:updateLock">
	            <a class="blue_btn" id="unlock" href="javascript:;" onclick="unlockFun()">解锁</a>
		    </shiro:hasPermission>
		    <shiro:hasPermission name="userController:updateStatus_0">
	            <a class="blue_btn" id="enable" href="javascript:;" onClick="statusFun('0');">启用</a>
		    </shiro:hasPermission>
		    <shiro:hasPermission name="userController:updateStatus_1">
	            <a class="blue_btn" id="disable" href="javascript:;" onclick="statusFun('1');" >禁用</a>
		    </shiro:hasPermission>
        </div> --%>
    </div>
    <div style="overflow: auto; width:98%;margin: auto;">
	    <table id="menuList" class="table table-bordered table_inline"></table>
	</div>
</div>
 
</body>
</html>